<!DOCTYPE HTML>
<html>
<body>
<script src="../resources/js-test.js"></script>

<button id="untitled"></button>

<div id="spin"
     tabindex="0"
     role="spinbutton"
     aria-valuetext="5 of 9"
     aria-valuemin="1"
     aria-valuemax="9"
     aria-valuenow="5">42</div>

<div id="console"></div>
<script>
description("This tests that a spin button supports range value attributes.")

if (window.testRunner && window.accessibilityController) {
    testRunner.dumpAsText();

    function endsWith(str, suffix) {
        str = '' + str;
        return str.substr(str.length - suffix.length) == suffix;
    }

    var untitled = document.getElementById('untitled');
    untitled.focus();
    window.axUntitled = accessibilityController.focusedElement;

    var spin = document.getElementById('spin');
    spin.focus();
    window.axSpin = accessibilityController.focusedElement;

    // Test range value attributes.
    shouldBe("endsWith(axSpin.intValue, '5')", "true");
    shouldBe("endsWith(axSpin.minValue, '1')", "true");
    shouldBe("endsWith(axSpin.maxValue, '9')", "true");
    shouldBe("endsWith(axSpin.valueDescription, '5 of 9')", "true");

    // Make sure the title doesn't come from the inner text. It should just be empty if
    // not otherwise specified.
    shouldBe("axSpin.name", "axUntitled.name");
}

</script>

</body>
</html>
